{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}</h2>
		</div>
		<div class="pull-right">
			<a class="btn btn-primary" href="{:url('add')}">新 增</a>
			<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
			<button class="btn btn-success list_sort" url="{:url('sort')}">排序</button>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<div class="tabs-wrapper">
			<ul class="nav nav-tabs">
				<li {if 0 eq $type}class="active"{/if}><a href="{:url('admin/channel/index',array('type'=>0))}">全部</a></li>
				{volist name=":config('nav_type_list')" id="item"}
				<li {if $key eq $type}class="active"{/if}>
					<a href="{:url('admin/channel/index',array('type'=>$key))}">{$item}</a>
				</li>
				{/volist}
			</ul>
			<div class="tab-content">

				<div class="table-responsive clearfix">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="30"><input class="checkbox check-all" type="checkbox"></th>
								<th width="60">ID</th>
								<th>名称</th>
								<th>URL</th>
								<th width="120">排序</th>
								<th>状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							{volist name="tree" id="list"}
							<tr>
								<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$list.id}"></td>
								<td>{$list['id']}</td>
								<td>
									{$list['level_show']}
									<a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="title" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['title']} </a>
									<a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$list['id'])}">
										<i class="fa fa-plus-square"></i>
									</a>
								</td>
								<td>{$list['url']}</td>
								<td><a href="#" class="editable editable-click" data-id="{$list['id']}" data-name="sort" data-type="text" data-pk="{$list['id']}" data-url="{:url('editable')}">{$list['sort']}</a></td>
								<td>
									{if $list['status']}
									<span class="label label-primary">{$list.status|get_status_title}</span>
									{else/}
									<span class="label label-danger">{$list.status|get_status_title}</span>
									{/if}
								</td>
								<td>
									<a title="编辑" href="{:url('edit?id='.$list['id'].'&pid='.$list['pid'])}">编辑</a>
									<a title="{$list.status|show_status_op}" href="{:url('setStatus?ids='.$list['id'].'&status='.abs(1-$list['status']))}" class="ajax-get">{$list.status|show_status_op}</a>
									<a title="删除" href="{:url('del?id='.$list['id'])}" class="confirm ajax-get">删除</a>
								</td>
							</tr>
							{/volist}
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}

{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function() {
	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});
	$.fn.editable.defaults.mode = 'popup';
	$.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
	'<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
	$('.editable').editable();
});
</script>
{/block}